import sys
import pygame

def check_events(ship):
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            sys.exit()
        elif event.type == pygame.KEYDOWN:
            if event.key == pygame.K_w:  # wasd 控制方向
                ship.moving_up = True
            elif event.key == pygame.K_a:  # wasd 控制方向
                ship.moving_left = True
            elif event.key == pygame.K_s:  # wasd 控制方向
                ship.moving_down = True
            elif event.key == pygame.K_d:  # wasd 控制方向
                ship.moving_right = True

        elif event.type == pygame.KEYUP:
            if event.key == pygame.K_w:  # wasd 控制方向
                ship.moving_up = False
            elif event.key == pygame.K_a:  # wasd 控制方向
                ship.moving_left = False
            elif event.key == pygame.K_s:  # wasd 控制方向
                ship.moving_down = False
            elif event.key == pygame.K_d:  # wasd 控制方向
                ship.moving_right = False



def update_screen(ai_settings, screen, ship):
    screen.fill(ai_settings.bg_color)
    ship.blitme()

    pygame.display.flip()